#ifndef __Modbus_master_H
#define	__Modbus_master_H

#include "ros/ros.h" //ros需要的头文件
#include <stdio.h>
#include <string.h>


//响应成功
extern uint8_t ModbusMasterResponseOk;
//定义接收数组指针
extern uint8_t ModbusMasterReceBuf[1024];
//定义发送数组指针
extern uint8_t ModbusMasterSendBuf[1024];
//定义接收长度指针
extern uint16_t *ModbusMasterReceLength;
//从站站号
extern uint8_t ModbusMaster_SlaveNum;
//临时寄存器，用于缓存读到的数据
extern uint8_t ModbusMasterTempBuf[32];


//读保持寄存器0x03
uint16_t ReadHoldRegister(uint16_t RegAddress, uint16_t num);

//写多个寄存器0x10
// uint16_t RegAddress 寄存器起始地址
// uint16_t* buf       数据指针
// uint16_t num        寄存器个数
// return         返回待发送数据长度
uint16_t WriteMultipleHoldRegister(uint16_t RegAddress, uint16_t *dataBuf, uint16_t num);


void AnalyzeResponse(void);//分析从站响应报文
void Response_03(void);
void Response_06(void);
void Response_10(void);
uint16_t MasterCalcCrc(unsigned char *chData, unsigned short uNo);
#endif
